'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, DECIMAL } = app.Sequelize;

  const Member = app.model.define('member', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    nickname: { type: STRING(50), allowNull: false, comment: '昵称' },
    avatar: { type: STRING(255), comment: '头像' },
    phone: { type: STRING(20), allowNull: false, unique: true, comment: '手机号' },
    password: { type: STRING(100), allowNull: false, comment: '密码' },
    points: { type: INTEGER, defaultValue: 0, comment: '会员积分' },
    balance: { type: DECIMAL(10, 2), defaultValue: 0, comment: '账户余额' },
    status: { type: INTEGER, defaultValue: 1, comment: '状态：1-正常，0-禁用' },
    createdAt: DATE,
    updatedAt: DATE,
  });

  return Member;
};
